package com.example.enjoyarkuix;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.enjoyarkuix.bridge.BridgeUtil;

import ohos.ace.adapter.capability.bridge.MethodData;

public class BridgeEntryActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bridge_entry);

        ImageView ivTopBarBack = (ImageView) findViewById(R.id.ivTopBarBack);
        ivTopBarBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        TextView title = (TextView) findViewById(R.id.tvTopBarTitle);
        title.setText("原生Activity");

        findViewById(R.id.sendMessge).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String[] data = { "message", "from", "android" };
                BridgeUtil.getBridgeTest().sendMessage(data);
            }
        });

        findViewById(R.id.method).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Object[] paramObject = {};
                MethodData methodData = new MethodData("jsMethod", paramObject);
                BridgeUtil.getBridgeTest().callMethod(methodData);
            }
        });


    }
}